package dyy.zc.campuspay.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

import dyy.zc.campuspay.R;
import dyy.zc.campuspay.base.BaseActivity;
import dyy.zc.campuspay.utils.ToastUtils;
import dyy.zc.campuspay.views.CleanableEditText;

public class ReChargeActivity extends BaseActivity {

    private TextView ok,title;
    private CleanableEditText price;

    @Override
    protected void findViewByIDS() {
        ok = findViewsById(R.id.tv_ok);
        title = findViewsById(R.id.top_tv_title);
        price = findViewsById(R.id.tv_chongzhijine);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recharge);
        initData();
        bind();
    }

    private void bind() {
        ok.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!price.getText().toString().equals("")){
                    String p = price.getText().toString();
                    if (Double.parseDouble(p)>0) {
                        Intent intent = new Intent(ReChargeActivity.this,PayStyleActivity.class);
                        intent.putExtra("price",p);
                        startActivity(intent);
                    }else {
                        ToastUtils.shortToast(ReChargeActivity.this,"请输入正确的充值金额");
                    }
                }else {
                    ToastUtils.shortToast(ReChargeActivity.this,"请输入充值金额");
                }
            }
        });
    }


    private void initData() {
        title.setText("充值");
    }
}
